package cn.tedu.basic;

import java.util.*;

public class Test3 {
    public static void main(String[] args) {
        ArrayList al =new ArrayList();
        al.add(88);
        al.add(77);
        al.add(78);
        al.add(79);
        al.add(89);
        System.out.println(al);
        al.add(89);
        al.add(null);
        System.out.println(al);
        Iterator It = al.iterator();
        while (It.hasNext()){
            Object o =It.next();
            System.out.println(o);
        }
        ListIterator lt =al.listIterator();
        while (lt.hasNext()){
            Object o =lt.next();
            System.out.println(o);
        }
        while (lt.hasPrevious()){
            Object o=lt.previous();
            System.out.println(o);
        }
        for (int i = 0; i <al.size() ; i++) {
            Object o=al.get(i);
            System.out.println(o);
        }
        for(Object o : al){
            System.out.println(o);
        }
        ArrayList al1 =new ArrayList();
        Object[] ob =new Object[10];
        int n =0;
        ob[0]="you";
        ob[n++]="are";
        ob[n++]="my";
        ob[n++]="love";
        if (n>ob.length){
            Arrays.copyOf(ob,100);
        }
        System.out.println(ob);

        LinkedList lk =new LinkedList();
        lk.add(88);
        lk.add(89);
        lk.add(88);
        lk.add(99);
        lk.add(null);
        lk.addFirst(87);
        lk.addLast(100);
        lk.size();
        //hashset,无序，不可重复，无下标，仅存一个null
        HashSet hs =new HashSet();
        hs.add(89);
        hs.add(88);
        hs.add(87);
        hs.add(null);
        hs.add(88);
        hs.add(null);
        System.out.println(hs);
        Iterator hs1 =hs.iterator();
        while (hs1.hasNext()){
            Object o =hs1.next();
        }
        for(Object o : hs){
            System.out.println(o);
        }
        //
        HashSet ha =new HashSet();
        ha.add("mbnbkmg");
        ha.add(6464);
        ha.add('f');
        ha.add(5.8);
        ha.add(6464);
        ha.add(null);
        ha.add(8888);
        System.out.println(ha);
        Iterator ha1 =ha.iterator();
        while (ha1.hasNext()){
            Object o=ha1.next();
            System.out.println(o);
        }
        for(Object o : ha){
            System.out.println(o);
        }
        //Map<K,v>,键与值的关系
        Map<Integer ,String> m =new HashMap();
        m.put(111,"yumin");
        m.put(222,"jingkong");
        m.put(333,"liuyang");
        Set<Integer> s =m.keySet();
        Iterator it =s.iterator();
        while (it.hasNext()){
            Object o =it.next();
            System.out.println(o);//这只是迭代key
        }
        for(Integer i  : s){
            String st =m.get(i);
            System.out.println(i + st);
            if (st=="yumin"){
                System.out.println("right");
            }
        }
        Collection<String> co =m.values();
        Iterator<String> Ite =co.iterator();
        while (Ite.hasNext()){
            String str = Ite.next();
            System.out.println(str);
        }
        for(String s1 : co){
            System.out.println(s1);
        }

        Set<Map.Entry<Integer,String>> se =m.entrySet();
        Iterator ite =se.iterator();
        while (ite.hasNext()){
           Object  o =ite.next();
            System.out.println(o);
        }
        for(Object o : se){
            System.out.println(o);
        }


    }
}
